package com.br.aiops.schedule;

import com.br.aiops.config.ApplicationContextUtil;
import com.br.aiops.utils.Constants;
import org.springframework.stereotype.Component;

@Component
public class Schedules {

    public static AbstractSchedule getSchedule(int duration) {
        if (duration == Constants.SCHEDULE_ONE_MINUTE) {
            return ApplicationContextUtil.getBean(OneMinuteSchedule.class);
        } else if (duration == Constants.SCHEDULE_TWO_MINUTE) {
            return ApplicationContextUtil.getBean(TwoMinutesSchedule.class);
        } else if (duration == Constants.SCHEDULE_FIVE_MINUTE) {
            return ApplicationContextUtil.getBean(FiveMinuteSchedule.class);
        }
        throw new IllegalArgumentException("未知duration类型。");
    }
}
